# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=multidict
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=5.1.0
pkgrel=1
pkgdesc='Asyncio-based multidict implementation for Python (mingw-w64)'
arch=('any')
url="https://github.com/aio-libs/multidict"
license=('APACHE')
depends=("${MINGW_PACKAGE_PREFIX}-python-numpy")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-cython")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-psutil" "${MINGW_PACKAGE_PREFIX}-python-pytest-runner" "${MINGW_PACKAGE_PREFIX}-python-pytest-cov")
source=("https://github.com/aio-libs/multidict/archive/v${pkgver}/multidict-${pkgver}.tar.gz")
sha256sums=('1798708288851b808d2d03ea6046ca51bc44c228aaea12c9643a0a481ee41d8c')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py test || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
